package com.baseframe.chat.mapper;

import com.baseframe.chat.entity.SnsChatUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baseframe.chat.entity.vo.SnsChatUserVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**

* @description 针对表【sns_chat_user(用户私聊表)】的数据库操作Mapper
* @createDate 2023-07-12 03:54:03
* @Entity com.baseframe.chat.entity.SnsChatUser
*/
public interface SnsChatUserMapper extends BaseMapper<SnsChatUser> {

    @Select("select id, sender_id, receiver_id, content as message, send_time,(select username from base_user where id = sender_id ) as sender,(select username from base_user where id = receiver_id ) as receiver from sns_chat_user  where (sender_id = #{senderUserId} or receiver_id = #{senderUserId}) and (sender_id = #{receiverUserId} or receiver_id = #{receiverUserId} ) order by send_time;")
    List<SnsChatUserVO> getUserChatRecords(@Param("senderUserId") Long senderUserId, @Param("receiverUserId") Long receiverUserId);

}




